<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
</head>
<body>

  <div id='app'>
    <home></home>
  </div>

<script src='https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js'></script>
<script>
  // 定义混入
  const mixin = {
    data() {
      return {
        msg: 'mixin'
      }
    }
    ,methods: {
      changeMsg() {
        this.msg = "数据改变了"
      }
    }
    ,computed: {
      reverseMsg() {
        return this.msg.split('').reverse().join('');
      }
    }
  }
  const Home = {
    template: `
      <div>
        <h2>HOME页</h2>
        <p>{{ msg }}</p>
        <button @click="changeMsg">改变</button>
        <span>{{reverseMsg}}<span>
      </div>
    `
    ,data() {
      return {
        msg: '自己的msg'
      }
    }
    ,mixins: [mixin]
  }
  Vue.component("Home", Home);
  const app = new Vue({
    el: '#app'
  })
</script>
</body>
</html>